﻿#region License


// Virtual Essentials - http://www.Virtual-Essentials.com
// Copyright (c) 2005-2013
// 
//  This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;


using DotNetNuke.Framework;
using DotNetNuke.Web.Client.ClientResourceManagement;

namespace VirtualEssentials.DNN.Modules.Testimonials
{
    /// <summary>
    /// Summary description for Testimonial
    /// </summary>
    public partial class EditTestimonial : DotNetNuke.Entities.Modules.PortalModuleBase
    {
        protected void Page_Init(object sender, EventArgs e)
        {
           try
            {
            ServicesFramework.Instance.RequestAjaxScriptSupport();
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            //loading this to get the jquery ui css loaded.

           jQuery.RequestDnnPluginsRegistration();
      
            //register the view model js
            Page.ClientScript.RegisterClientScriptResource(typeof(Testimonials.Testimonial), "VirtualEssentials.DNN.Modules.Testimonials.js.TestimonialViewModel.js");

            //add controls to hold the module and tab id, required for the 
            //ActiveModule support needed on the WebAPI controller
            HtmlGenericControl veModuleId = new HtmlGenericControl();
            veModuleId.Attributes.Add("class", "veModuleId");
            veModuleId.Attributes.Add("style", "display:none;");
            Page.Controls.Add(veModuleId);
            veModuleId.InnerText = this.ModuleId.ToString();

            HtmlGenericControl veTabID = new HtmlGenericControl();
            veTabID.Attributes.Add("class", "veTabID");
            veTabID.Attributes.Add("style", "display:none;");
            Page.Controls.Add(veTabID);
            veTabID.InnerText = this.TabId.ToString();


            //build script block
            StringBuilder jQueryDocReadyScript = new StringBuilder();
            jQueryDocReadyScript.AppendLine("$(document).ready(function() {");
            //add view model
            jQueryDocReadyScript.AppendLine("ko.applyBindings(new TestimonialViewModel());");
            jQueryDocReadyScript.AppendLine("jQuery(\"[id$='veManageTestimonialTabs']\").dnnTabs();");
            
            jQueryDocReadyScript.AppendLine("});");
            
            //register to page
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "jQueryDocReadyScriptVE_" + ModuleId, jQueryDocReadyScript.ToString(), true);

            }
             catch (Exception exc)
             {
                 DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
             }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        
        }

    
    }
}